package com.telchina.common.mq;


import com.telchina.data.meterReading.service.IMeterreadingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 消息监听器
 *
 * @author haozhen
 * @version 1.0
 * @since 2023/3/1
 */
@Component
public class Receiver {
    private static final Logger log = LoggerFactory.getLogger(Receiver.class);

    @Autowired
    private IMeterreadingService meterreadingService;

    @RabbitListener(queues = "topicqueue")
    public void displayTopic(String message) {
        log.info("从topicqueue1取出消息 {}", message);
        try {
            meterreadingService.saveMeterReading(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
